<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function Student(name, age, sno) {
      this.name = name
      this.age = age
      this.sno = sno
      // function running(){
      //   console.log(this.name + 'running')
      // }
      // function eating(){
      //   console.log(this.age + 'running')
      // }
      // function studing(){
      //   console.log(this.sno + 'running')
      // }
    }
    // 将相同的代码放在原型上
    Student.prototype.running = function () {
      console.log(this.name + 'running')
    }
    Student.prototype.eating = function () {
      console.log(this.age + 'eating')
    }
    Student.prototype.studing = function () {
      console.log(this.sno + 'studing')
    }
    var stu1 = new Student('小黄',18,'123')
    stu1.running()
    stu1.eating()
    stu1.studing()
    
  </script>
</body>

</html>